//引入路由组件
// import Home from '@/pages/Home';
// import Register from '@/pages/Register';
// import Login from '@/pages/Login';
// import search from '@/pages/Search';
// import Detail from '@/pages/Detail';
// import AddCartSuccess from "@/pages/AddCartSuccess";
// import ShopCart from "@/pages/ShopCart";
// import Trade from "@/pages/Trade";
// import Pay from "@/pages/Pay";
// import PaySuccess from "@/pages/PaySuccess";
// import Center from "@/pages/Center";

// //引入二级路由
// import MyOrder from "@/pages/Center/myOrder";
// import GroupOrder from "@/pages/Center/groupOrder";

export default [
    {
        path: "/home",
        component:()=>import("@/pages/Home"),
        meta: { show: true },
        name: "home"
    },
    {
        path: "/register",
        component: ()=>import("@/pages/Register"),
        meta: { show: false }

    },
    {
        path: "/login",
        component:()=>import("@/pages/Login"),
        meta: { show: false }
    },
    {
        path: "/search/:keyword?",
        component: ()=>import("@/pages/Search"),
        meta: { show: true },
        name: "search"
    },
    {
        path: "/detail/:skuId",
        component: ()=>import("@/pages/Detail"),
        meta: { show: false },
        name: "detail"
    },
    {
        path: "/addcartsuccess",
        component: ()=>import("@/pages/AddCartSuccess"),
        meta: { show: false },
        name: "addcartsuccess"
    },
    {
        path: "/shopcart",
        component: ()=>import("@/pages/ShopCart"),
        meta: { show: true },
        name: "shopcart"
    },
    {
        path: "/trade",
        component:()=>import("@/pages/Trade"),
        meta: { show: true },
        name: "trade",
        //路由独享守卫
        beforeEnter: (to, from, next) => {
            if (from.path == "/shopcart"||from.path == "/pay") {
                next()
            } else {
                next(false);
            }
        }
    },
    {
        path: "/pay",
        component: ()=>import("@/pages/Pay"),
        meta: { show: true },
        name: "pay",
        //路由独享守卫
        beforeEnter: (to, from, next) => {
            if (from.path == "/trade") {
                next()
            } else {
                next(false)
            }
        }
    },
    {
        path: "/paysuccess",
        component: ()=>import("@/pages/PaySuccess"),
        meta: { show: true },
        name: "paysuccess",
        //路由独享守卫
        beforeEnter: (to, from, next) => {
            if (from.path == "/pay") {
                next()
            } else {
                next(false)
            }
        }
    },
    {
        path: "/center",
        component: ()=>import( "@/pages/Center"),
        meta: { show: true },
        name: "center",
        //二级路由
        children: [
            {
                path: "myorder",
                component: ()=>import("@/pages/Center/myOrder"),
                name: "myorder",
            },
            {
                path: "grouporder",
                component: ()=>import("@/pages/Center/groupOrder"),
                name: "grouporder",
            },
            //重定向，在center时，立马让它定向到myorder
            {
                path: "/center",
                redirect: "/center/myorder"
            }
        ],
    },
    {
        //重定向，在项目跑起来的时候，立马让它定向到首页
        path: '*',
        redirect: '/home'
    }
]